package com.test.demo;

public class ServerInfoForAlarm {
	public int getnID() {
		return nID;
	}

	public void setnID(int nID) {
		this.nID = nID;
	}

	public int getnDevID() {
		return nDevID;
	}

	public void setnDevID(int nDevID) {
		this.nDevID = nDevID;
	}

	public String getStrUsername() {
		return strUsername;
	}

	public void setStrUsername(String strUsername) {
		this.strUsername = strUsername;
	}

	public String getStrPassword() {
		return strPassword;
	}

	public void setStrPassword(String strPassword) {
		this.strPassword = strPassword;
	}

	public long getlLastMsgFreshTime() {
		return lLastMsgFreshTime;
	}

	public void setlLastMsgFreshTime(long lLastMsgFreshTime) {
		this.lLastMsgFreshTime = lLastMsgFreshTime;
	}

	public long getlLastMsgGetTime() {
		return lLastMsgGetTime;
	}

	public void setlLastMsgGetTime(long lLastMsgGetTime) {
		this.lLastMsgGetTime = lLastMsgGetTime;
	}

	int nID=-1;
	int nDevID=0;
	int nNewAlarmMsg=0;
	public int getnNewAlarmMsg() {
		return nNewAlarmMsg;
	}

	public void setnNewAlarmMsg(int nNewAlarmMsg) {
		this.nNewAlarmMsg = nNewAlarmMsg;
	}

	String strUsername=null;
	String strPassword=null;
	long lLastMsgFreshTime=0;
    long lLastMsgGetTime=0;
    public boolean isMatch(int nDevID, String strUsername, String strPassword){
     
    	boolean isMatch=false;
   
      
            if (this.nDevID!=nDevID) {
                return false;
            }
            
            
            if ((this.strUsername==null || strUsername==null) && !(this.strUsername==null && strUsername==null)) {
                return false;
            }
            
            if ((this.strPassword==null || strPassword==null) && !(this.strPassword==null && strPassword==null)) {
                return false;
            }
            
            if (this.strUsername==null && strUsername==null && this.strPassword==null && strPassword==null){
                return true;
            }else if (this.strUsername==null && strUsername==null){
                
                if (this.strPassword.equals(strPassword)) {
                    return true;
                }
            }else if (this.strPassword==null && strPassword==null){
            	
                if (this.strUsername.equals(strUsername)) {
                    return true;
                }
            }else{
                if (this.strUsername.equals(strUsername) && this.strPassword.equals(strPassword)) {
                    return true;
                }
            }
            
 
        return   isMatch;
    }
    
     
    
	public ServerInfoForAlarm(int nID, int nDevID, int nNewAlarmMsg, String strUsername, String strPassword, long lLastMsgFreshTime, long lLastMsgGetTime){
		this.nID=nID;
		this.nDevID=nDevID;
		this.strUsername=strUsername;
		this.strPassword=strPassword;
		this.lLastMsgFreshTime=lLastMsgFreshTime;
		this.lLastMsgGetTime=lLastMsgGetTime;
		this.nNewAlarmMsg = nNewAlarmMsg;
	}
}
